package app;

import java.io.PrintStream;
import java.util.Vector;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import ui.Element;

public class ArabicElement extends Element
{
  private static byte[] w_str;
  public static final int LINE_HEIGHT = 24;
  static int max_char;
  public static Image[] ARABIC_CHARACTERS = new Image[95];
  private Vector lines;
  public static short[] PATTERN = { 0, 0, 0, 0, 0, 8, 0, 0, 2, 3, 65, 65, 97, 126, 60, 0, 0, 0, 0, 0, 0, 0, 0, 4, 8, 16, 28, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 8, 16, 28, 24, 0, 24, 0, 0, 0, 0, 0, 0, 0, 124, 198, 192, 96, 48, 48, 0, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 54, 48, 30, 56, 0, 0, 0, 0, 0, 0, 60, 64, 8, 24, 24, 24, 24, 24, 24, 24, 16, 0, 0, 0, 0, 0, 60, 64, 8, 24, 24, 24, 24, 24, 31, 15, 0, 0, 0, 0, 0, 8, 16, 24, 16, 8, 24, 24, 24, 24, 24, 24, 16, 0, 0, 0, 0, 8, 16, 24, 16, 8, 24, 24, 24, 24, 31, 15, 0, 0, 0, 0, 0, 0, 0, 4, 8, 12, 8, 2, 5, 9, 15, 7, 1, 6, 124, 56, 0, 0, 0, 8, 24, 24, 24, 24, 24, 24, 24, 16, 8, 16, 24, 16, 0, 0, 0, 8, 24, 24, 24, 24, 24, 24, 31, 15, 16, 32, 48, 32, 0, 0, 0, 0, 16, 32, 48, 34, 3, 1, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 64, 128, 195, 135, 8, 16, 158, 130, 194, 252, 120, 0, 0, 0, 0, 0, 0, 16, 32, 48, 32, 0, 67, 131, 193, 255, 126, 0, 0, 0, 0, 8, 24, 24, 24, 24, 24, 24, 24, 24, 16, 0, 0, 0, 0, 0, 0, 8, 24, 24, 24, 24, 24, 24, 31, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 1, 255, 254, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 66, 131, 129, 255, 126, 0, 0, 8, 0, 0, 0, 0, 5, 0, 0, 6, 7, 9, 9, 15, 14, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 2, 3, 1, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 66, 131, 129, 255, 126, 0, 0, 0, 0, 0, 0, 0, 16, 0, 40, 0, 2, 3, 1, 255, 254, 0, 0, 0, 0, 0, 0, 0, 8, 0, 20, 0, 66, 131, 129, 255, 126, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 44, 6, 255, 254, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 48, 76, 31, 35, 64, 72, 96, 127, 62, 0, 0, 0, 0, 0, 0, 0, 24, 44, 6, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 76, 31, 35, 64, 64, 96, 127, 62, 0, 0, 0, 0, 16, 0, 0, 24, 44, 6, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 48, 76, 31, 35, 64, 64, 96, 127, 62, 0, 0, 0, 0, 0, 0, 4, 6, 3, 33, 63, 30, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 4, 6, 3, 33, 63, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 1, 1, 1, 6, 124, 56, 0, 0, 0, 0, 0, 4, 0, 0, 2, 3, 1, 1, 1, 6, 124, 56, 0, 0, 0, 0, 0, 0, 0, 0, 1, 37, 255, 218, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 37, 191, 154, 144, 144, 240, 96, 0, 0, 0, 0, 4, 0, 10, 0, 1, 37, 255, 218, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 10, 0, 1, 37, 191, 154, 144, 144, 240, 96, 0, 0, 0, 0, 0, 0, 0, 6, 41, 49, 255, 222, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 9, 49, 191, 158, 144, 144, 240, 96, 0, 0, 0, 0, 4, 0, 0, 6, 41, 49, 255, 222, 16, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 6, 9, 49, 191, 158, 144, 144, 240, 96, 0, 0, 0, 32, 48, 32, 32, 38, 41, 49, 255, 254, 0, 0, 0, 0, 0, 0, 0, 32, 50, 32, 32, 38, 41, 49, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 34, 48, 24, 254, 252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 32, 32, 30, 28, 32, 64, 64, 96, 127, 62, 0, 0, 0, 0, 0, 0, 0, 14, 31, 14, 255, 251, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 62, 28, 39, 67, 64, 96, 127, 62, 0, 0, 0, 16, 0, 0, 28, 34, 48, 24, 254, 252, 0, 0, 0, 0, 0, 0, 16, 0, 0, 28, 32, 32, 30, 28, 32, 64, 64, 96, 127, 62, 0, 0, 0, 0, 4, 0, 0, 14, 31, 14, 255, 251, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 28, 62, 28, 39, 67, 64, 96, 127, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 5, 9, 15, 1, 255, 254, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 5, 73, 143, 129, 255, 126, 0, 0, 0, 0, 0, 0, 9, 0, 0, 2, 5, 9, 15, 1, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 2, 5, 9, 79, 71, 97, 126, 60, 0, 0, 0, 0, 1, 6, 24, 48, 24, 6, 1, 255, 254, 0, 0, 0, 0, 0, 0, 0, 1, 3, 11, 19, 91, 147, 131, 255, 126, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, 3, 3, 3, 255, 254, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, 3, 3, 3, 67, 67, 99, 126, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 11, 249, 253, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 59, 121, 109, 102, 96, 96, 64, 0, 0, 0, 0, 8, 0, 0, 2, 3, 1, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 2, 3, 65, 65, 97, 126, 60, 0, 0, 0, 0, 0, 0, 0, 56, 28, 38, 25, 255, 238, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 9, 9, 15, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 10, 20, 255, 255, 18, 14, 6, 0, 0, 0, 0, 0, 0, 0, 0, 2, 5, 9, 15, 7, 1, 6, 124, 56, 0, 0, 0, 0, 0, 0, 3, 7, 8, 16, 158, 130, 194, 252, 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 131, 193, 255, 126, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 1, 255, 254, 0, 0, 36, 0, 72, 0, 0, 0, 0, 0, 3, 7, 8, 16, 158, 130, 194, 252, 120, 0, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 131, 193, 255, 126, 0, 0, 0, 0, 0, 15, 16, 3, 3, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 16, 34, 51, 35, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 3, 0, 0, 0, 1, 19, 32, 48, 32, 0, 0, 0, 0, 0, 2, 3, 3, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 8, 12, 12, 8, 136, 200, 88, 48, 200, 240, 0, 0, 0, 0, 0, 0, 8, 24, 24, 24, 152, 216, 124, 55, 227, 192, 0, 0, 0, 0, 0, 18, 36, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 36, 72, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 102, 170, 238, 68, 136, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 36, 72, 0, 0, 2, 4, 8, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 8, 16, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 10, 14, 4, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 10, 14, 4, 8, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 8, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 4, 8, 16, 0, 0, 2, 74, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 74, 52, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 10, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 10, 12, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 8, 16, 24, 22, 7, 9, 9, 15, 14, 0, 0, 0, 0, 0, 0, 18, 36, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

  public static byte[] f = { 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0 };

  public static byte[] e = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0 };

  public static short[][] g = { { 223, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 172, 172, 0, 0, 0, 177, 0, 0, 180, 0, 182, 0, 184, 0, 186, 0, 188, 0, 0, 0, 0, 0, 194, 0, 196, 0, 198, 0, 200, 0, 0, 0, 204, 0, 206, 0, 208, 0, 210, 0, 0, 213, 0, 215, 0, 217, 0, 219, 0, 221, 0, 223, 0, 225, 0, 0, 231, 231, 0, 231, 231, 0, 0, 0, 0, 0, 0, 241, 241, 242, 243, 245, 245, 247, 247, 249, 249, 251, 251, 253, 253, 0, 241 }, { 0, 0, 0, 0, 0, 166, 0, 168, 0, 0, 171, 0, 0, 174, 0, 176, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 206, 207, 0, 0, 210, 211, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 227, 0, 0, 0, 230, 0, 0, 233, 0, 0, 0, 0, 0, 239, 0, 241, 241, 242, 243, 245, 245, 247, 247, 249, 249, 251, 251, 253, 253, 0, 241 } };

  public ArabicElement(byte[] arabic, int left, int top, int width)
  {
    super(left, top);
    this.width = width;
    if (ARABIC_CHARACTERS[0] == null)
      initialize();
    this.lines = getLines(arabic, arabic.length, width);
    this.height = (this.lines.size() * 24);
  }

  public void draw(Graphics g, int x, int y, int startY, int stopY, boolean selected)
  {
    y += this.top + 5;
    int i;
    for (i = 0; (i < this.lines.size()) && (y < startY); ++i) {
      y += 24;
    }
    for (; (i < this.lines.size()) && (y < stopY); ++i)
    {
      byte[] b = (byte[])(byte[])(byte[])this.lines.elementAt(i);
      drawLine(g, b, b.length - 1, 0, y, this.width + x - 5);
      y += 24;
    }
  }

  public static void initialize()
  {
    for (int k1 = 0; k1 < 95; ++k1)
      ARABIC_CHARACTERS[k1] = createChar((short)(160 + k1));
  }

  public static int getByte(byte byte0)
  {
    return byte0 & 0xFF;
  }

  private static int c(byte[] buffer_surah, int i1)
  {
    return ((buffer_surah[i1] == 1) && (getByte(buffer_surah[(i1 + 1)]) < 10)) ? 8 : 16;
  }

  public static Vector getLines(byte[] buffer_surah, int len, int width)
  {
    Vector lines = new Vector();
    max_char = (width >> 2) + 10;
    byte[] buf = new byte[max_char];
    int x1 = width;
    int i3 = 0;
    int i = 0;
    int len2 = 0;
    int w1 = x1;
    System.out.println("w1 : " + w1);
    int left = 9;
    boolean[] aflag = new boolean[1];

    while (i < len)
    {
      if (buffer_surah[i] == 0)
      {
        byte[] line = new byte[len2];
        System.arraycopy(buf, 0, line, 0, len2);
        lines.addElement(line);
        break;
      }
      if (i == i3)
      {
        for (i3 = ((buffer_surah[i3] == 1) || (buffer_surah[i3] == 2)) ? i + 2 : i + 1; (i3 < len) && (getByte(buffer_surah[i3]) >= 160); ++i3);
        if (i3 > len)
          i3 = len;
        int w_str = 0;
        int l3;
        if ((buffer_surah[i] == 1) || (buffer_surah[i] == 2))
        {
          w_str = c(buffer_surah, i);
          l3 = i + 2;
        }
        else {
          l3 = i;
        }
        for (; l3 < i3; ++l3) {
          if (getByte(buffer_surah[l3]) < 240)
            w_str += 8;
        }
        if ((w1 < width) && (w1 - w_str < left) && (width - w_str >= left))
        {
          if ((((buffer_surah[i] == 1) || (buffer_surah[i] == 2))) && (w1 >= c(buffer_surah, i) + left - 1))
          {
            w1 = width;
            buf[(len2++)] = buffer_surah[i];
            buf[(len2++)] = buffer_surah[(++i)];

            byte[] line = new byte[len2];
            System.arraycopy(buf, 0, line, 0, len2);
            lines.addElement(line);
            len2 = x1 = 0;
          }

          w1 = width;

          byte[] line = new byte[len2];
          System.arraycopy(buf, 0, line, 0, len2);
          lines.addElement(line);
          len2 = x1 = 0;
        }

      }

      if ((w1 != width) || (buffer_surah[i] != 32))
        if ((buffer_surah[i] == 1) || (buffer_surah[i] == 2))
        {
          if ((w1 < c(buffer_surah, i) + 1) || (len2 >= max_char - 1))
          {
            w_str = new byte[len2];
            System.arraycopy(buf, 0, w_str, 0, len2);
            lines.addElement(w_str);
            w1 = width;
            len2 = x1 = 0;
          }
          else {
            w1 -= c(buffer_surah, i);
            buf[(len2++)] = buffer_surah[i];
            buf[(len2++)] = buffer_surah[(++i)];
            if ((w1 < left) || (len2 >= max_char))
            {
              w_str = new byte[len2];
              System.arraycopy(buf, 0, w_str, 0, len2);
              lines.addElement(w_str);
              w1 = width;
              len2 = x1 = 0;
            }
          }
        }
        else if (buffer_surah[i] != 0)
        {
          buf[(len2++)] = (byte)getLocationChar(i, buffer_surah, len, aflag);
          if (aflag[0] != false)
            x1 = len2;
          if (getByte(buffer_surah[i]) < 240)
            w1 -= left - 1;
          if ((w1 < left) || (len2 >= max_char))
          {
            w_str = new byte[len2];
            System.arraycopy(buf, 0, w_str, 0, len2);
            lines.addElement(w_str);
            w1 = width;
            len2 = x1 = 0;
          }
        }
      ++i;
    }
    w_str = new byte[len2];
    System.arraycopy(buf, 0, w_str, 0, len2);
    lines.addElement(w_str);
    return lines;
  }

  private static void drawLine(Graphics g1, byte[] abyte0, int len, int x, int y, int width)
  {
    int right = width;
    int w1 = 0;
    for (; (len >= 0) && (((abyte0[len] == 0) || ((abyte0[len] == 32) && (getByte(abyte0[(len - 1)]) > 2)))); --len);
    if (len < 0)
      return;
    if (x > 0)
    {
      for (int i2 = 0; i2 <= len; ++i2) {
        if (getByte(abyte0[i2]) < 240)
          ++w1;
      }
      if (((w1 = (width - 18 >> 3) - w1 - 1) + len >= max_char) || (w1 <= 0))
        w1 = 0;
      if (w1 != 0)
      {
        for (int j2 = len; j2 >= x; --j2) {
          abyte0[(j2 + w1)] = abyte0[j2];
        }
        for (int k2 = x; k2 < x + w1; ++k2)
          abyte0[k2] = -44;
      }
    }
    else
    {
      w1 = 0;
    }
    for (int l2 = 0; l2 <= len + w1; ++l2)
    {
      if (abyte0[l2] == 1)
      {
        right -= ((getByte(abyte0[(l2 + 1)]) < 10) ? 8 : 16);
        ++l2;
      }
      else if (abyte0[l2] == 2)
      {
        ++l2;
        right -= 16;
      }
      else if (getByte(abyte0[l2]) >= 240)
      {
        short word0;
        if (((word0 = (short)getByte(abyte0[l2])) == 248) || (word0 == 243))
        {
          drawChar(g1, right + 6, y + 4, word0);
        }
        else if (word0 == 250)
        {
          drawChar(g1, right + 9, y - 3, word0);
        }
        else if ((l2 > 0) && (word0 != 240) && (getByte(abyte0[(l2 - 1)]) == 250))
        {
          drawChar(g1, right + 5, y - 6, word0);
        }
        else if (word0 == 246)
          drawChar(g1, right + 6, y - 5, word0);
        else {
          drawChar(g1, right + 6, y - 4, word0);
        }
      }
      else if ((drawChar(g1, right, y, (short)getByte(abyte0[l2]))) || (l2 > 0)) {
        right -= 8;
      }
    }
  }

  public static final short getLocationChar(int i1, byte[] abyte0, int len, boolean[] aflag)
  {
    short char1 = (short)getByte(abyte0[i1]);
    if (aflag != null)
      aflag[0] = false;
    if (char1 < 160)
      return char1;
    short word1 = 0;
    int j1;
    for (j1 = i1 - 1; (j1 >= 0) && (getByte(abyte0[j1]) >= 240); --j1);
    if ((j1 == 0) || ((j1 >= 1) && (abyte0[(j1 - 1)] != 1) && (abyte0[(j1 - 1)] != 2))) {
      word1 = (short)getByte(abyte0[j1]);
    }
    else if ((j1 > 2) && (((abyte0[(j1 - 1)] == 1) || (abyte0[(j1 - 1)] == 2))) && (getByte(abyte0[(j1 - 2)]) <= 2))
      word1 = (short)getByte(abyte0[j1]);
    short word2 = 0;
    for (j1 = i1 + 1; (j1 < len) && (getByte(abyte0[j1]) >= 240); ++j1);
    if (j1 >= len)
      return char1;
    word2 = (short)getByte(abyte0[j1]);
    if (char1 >= 240)
    {
      if ((word1 == 220) && (((word2 == 175) || (word2 == 165) || (word2 == 167) || (word2 == 170))))
        return char1;
      if ((aflag != null) && (char1 != 240) && (word2 >= 160) && (word1 >= 160) && (f[(word2 - 160)] != 0) && (e[(word1 - 160)] != 0))
        aflag[0] = true;
      return char1;
    }
    if ((char1 == 220) && (((word2 == 175) || (word2 == 165) || (word2 == 167) || (word2 == 170)))) {
      char1 = 238;
    }
    else if (word1 == 220)
    {
      if (char1 == 175)
        return 237;
      if (char1 == 165)
        return 234;
      if (char1 == 167)
        return 235;
      if (char1 == 170)
        return 236;
    }
    short word4;
    if ((word2 >= 160) && (f[(word2 - 160)] != 0) && ((word4 = g[0][(char1 - 160)]) != 0))
    {
      char1 = word4;
      if (aflag != null)
        aflag[0] = true;
    }
    //short word4;
    if ((word1 >= 160) && (e[(word1 - 160)] != 0) && ((word4 = g[1][(char1 - 160)]) != 0))
      char1 = word4;
    return char1;
  }

  public static final boolean drawChar(Graphics g1, int x, int y, short chr)
  {
    if (chr == 38)
      return true;
    if (chr == 35)
      return true;
    if (chr < 160)
    {
      return false;
    }

    g1.drawImage(ARABIC_CHARACTERS[(chr - 160)], x - 7, y, 20);
    return true;
  }

  private static Image createChar(short word0)
  {
    if (word0 < 160)
      return null;
    int[] ai = new int[''];
    int l1 = word0 - 160 << 4;
    int color = (word0 < 240) ? -16777216 : -8847360;
    for (int i1 = 1; i1 < 16; ++i1)
    {
      short word1 = PATTERN[(l1 + i1)];
      for (int j1 = 7; j1 >= 0; --j1)
      {
        ai[(j1 + (i1 - 1) * 8)] = (((word1 & 0x1) == 1) ? color : 0);
        word1 = (short)(word1 >> 1);
      }

    }

    short word2 = PATTERN[l1];
    for (int k1 = 7; k1 >= 0; --k1)
    {
      ai[(k1 + 120)] = (((word2 & 0x1) == 1) ? color : 0);
      word2 = (short)(word2 >> 1);
    }

    return Image.createRGBImage(ai, 8, 16, true);
  }
}